package com.mango.game.dtos;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
public class QueryDTO<T> {

    // 分页：当前页
    private Integer currentPage;

    // 分页：页大小
    private Integer pageSize;

    // 时间范围：开始段
    private LocalDateTime startDataTime;

    // 时间范围：结束段
    private LocalDateTime endDateTime;

    // 排序字段集合（格式：created_at ASC，updated_at DESC）
    private List<String> sortFields;

    // 模糊匹配：字段集合
    private List<String> likeFields;

    // 模糊匹配：匹配值
    private String likeValue;

    // 业务扩展数据
    private QueryExtendDTO extend;

    // 对应的DB
    private T entity;

    public QueryDTO() {
        this.currentPage = 1;
        this.pageSize = 200;
        this.startDataTime = LocalDateTime.of(1970, 1, 1, 0, 0, 0);
        this.endDateTime = LocalDateTime.now();
        this.sortFields = Arrays.asList("created_at DESC", "updated_at DESC");
        this.likeFields = new ArrayList<>();
        this.likeValue = "";
        this.extend = new QueryExtendDTO();
        this.entity = null;
    }

}
